package com.qf.test.test.service;

import com.qf.test.test.dao.UserDao;
import com.qf.test.test.pojo.User;

import javax.annotation.PreDestroy;
import java.util.ArrayList;
import java.util.List;

public class UserServiceImpl1 implements UserService {
    UserDao userDao;

    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        System.out.println("UserServletimpl1的set方法执行了");
        this.userDao = userDao;
    }

    public UserServiceImpl1() {
        System.out.println("UserServiceImpl1的无参构造执行了");
    }

    /**
     * 初始化
     */
    @PreDestroy
    public void init(){
        System.out.println("UserServiceImpl1初始话init");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("UserServiceImpl1的销毁方法执行了");
    }

    /**
     * 业务方法
     */
    public void registUser() {
        userDao.inserUser();
        System.out.println("userDaoimpl接口的第一种实现");
    }

    public List<User> findUserAll() {
        System.out.println("UserServiceImpl1 执行了findUserAll 方法");
        return new ArrayList<User>();
    }

    public void insertUser(User user) {
        System.out.println("UserServiceImpl1 执行了insertUser 方法");
    }

    public void updateUser(User uesr) {
        System.out.println("UserServiceImpl1 执行了updateUser 方法");
    }

    public void deleteUser(Integer id) {
        System.out.println("UserServiceImpl1 执行了deleteUser 方法");
        int i=1/0;//模拟发生了异常
    }
}
